package com.hsource.doctorcenter.service.user.impl;

import com.hsource.doctorcenter.service.user.UserService;
import com.hsource.doctorcenter.util.SignParams;
import com.hsource.doctorcenter.util.http.OkHttpUtil;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;

import java.security.NoSuchAlgorithmException;
import java.text.ParseException;

/**
 * @author yangYang
 * @version 1.0
 * @date 2020/9/23 9:16
 * @describe USER-SERVICE-IMPL
 */
@Service
public class UserServiceImpl implements UserService {
    @Value("${chunyutianxia.api-url}")
    private String apiUrl;

    /**
     * 同步用户信息
     * @param userId 用户id
     * @param password 用户密码
     * @return
     */
    @Override
    public String userLogin(String userId,String password) throws ParseException, NoSuchAlgorithmException {
        SignParams signParams = SignParams.newBuilder(userId).paramEntry("userId", userId).paramEntry("password", password);
        //调用接口返回数据
        return OkHttpUtil.postFormParams(apiUrl+"/cooperation/server/login",  signParams.getParams());
    }
}
